<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Sistema para Gestão de Entidades Sem Fins Lucrativos</title>
	<link rel="stylesheet" type="text/css" href="lib/ext/override.css" />
</head>

<body>


<div id="Ploading-mask"></div>
<div id="Ploading">
	<div class="Ploading-indicator">
		<center>
		<img src="img/loading.gif" style="vertical-align:top;"/>
		<br />
		Sistema para Gestão de Entidades Sem fins Lucrativos<br />
		<br />
		<span id="Ploading-msg">
			Carregando bibliotecas do ExtJS...
		</span>
		</center>
	</div>
</div>
		
<script type="text/javascript">document.getElementById('Ploading-msg').innerHTML = 'Carregando...';</script>



<link rel="stylesheet" type="text/css" href="lib/ext/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="css/estilo.css" />
<script type="text/javascript" src="lib/ext/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="lib/ext/ext-all.js"></script>
<script src="js/config.js" type="text/javascript"></script>


<script>
Ext.onReady(function() {
    var formLogin = new Ext.form.FormPanel({
        bodyBorder: 0,
		bodyStyle: 'padding:5px',
        fieldDefaults: {
            labelWidth: 55
        },
        defaultType: 'textfield',

        items: [
			/*
			{
				xtype: 'component',
				margin : '0 0 0 0',
				align:'center',
				autoEl: {
					tag: 'img',
					src: 'img/logo_sistema.png'
				}
			}
			*/
			{
	            fieldLabel: 'E-mail',
	            name: 'email',
	            anchor:'100%',  // anchor width by percentage
				allowBlank: false
	        }
	        ,{
	            inputType: 'password',
				fieldLabel: 'Senha',
	            name: 'senha',
	            anchor: '100%',  // anchor width by percentage
				allowBlank: false
	        }
        ],
        buttons: [{
            text: 'Enviar',
			handler : function(){
				var form = formLogin.getForm();
		
				if(form.isValid()){
					
					
					this.params = formLogin.form.getValues(true);
					
					
					
					Ext.Ajax.request({
						url: baseURL + '/service/index.php?controller=LoginController&service=efetuarLogin',
						success:  function(result){
							var objRetorno = Ext.decode(result.responseText);
					
							if(objRetorno.success == true){
								win.hide();
								window.location.href = "index.php";
							}else{
								Ext.MessageBox.alert("Mensagem", objRetorno.message);
							}
						},
						params: this.params,
						scope: this			
					});
					
					
					
				}else{
					alert("Preencha os campos obrigatórios");
				}
				
				
			}
        },{
            text: 'Reset'
        }]
    });

    var win = new Ext.Window({
        title: 'Login - Sistema para entidades sem fins lucrativos',
        width: 370,
        height:150,
        minWidth: 300,
        minHeight: 130,
        layout: 'fit',
		modal: true,
        plain: true,
        bodyPadding: 5,
        items: formLogin,
		closable : false
    });

    win.show();

    setTimeout(function() {
		Ext.get("Ploading").remove();
		Ext.get("Ploading-mask").fadeOut( {
			easing : "easeOut",
			duration : 0.7,
			remove : true
		})
	}, 250)
});
</script>


</body>
</html>
